﻿using CardPlay.Model.CardModel;

namespace CardPlay.Model.GameModel.Actions
{
    public class AddCardsAction : PileAction
    {
        public AddCardsAction(CardGame cardGame, PartLocation location, Card card) : base(cardGame, location)
        {
            PileBeingAdded = new CardPile();
            PileBeingAdded.AddCardToTop(card);
        }

        public AddCardsAction(CardGame cardGame, PartLocation location, CardPile cards) : base(cardGame, location)
        {
            PileBeingAdded = cards;
        }

        public CardPile PileBeingAdded
        {
            get; private set;
        }

        protected override void OnExecute()
        {
            SourcePile.AddCardsToTop(PileBeingAdded);
        }
        
        protected override void OnReverse()
        {
            SourcePile.RemoveCards(SourcePile.Count - PileBeingAdded.Count, PileBeingAdded.Count);
        }
    }
}
